package com.example.piece.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.example.piece.R
import com.example.piece.databinding.ItemHomeTypeBinding
import com.example.piece.entity.HomeTypeInfoEntity
import com.example.piece.BR

class HomeTypeAdapter(data: List<HomeTypeInfoEntity>) :BaseQuickAdapter<HomeTypeInfoEntity, BaseDataBindingHolder<ItemHomeTypeBinding>>(
    R.layout.item_home_type
) {




 /*   *//**  点击item  **/
    /*@RepeatClick*/
    fun onItemClickForDIY(entity: HomeTypeInfoEntity, position:Int) {
        onClickChooseFunction?.invoke(entity,position)

    }
    private var onClickChooseFunction: ((entity: HomeTypeInfoEntity, position:Int) -> Unit)? = null

   /**  点击item  **/
   /* @RepeatClick*/
    fun onItemClickChooseFunction(onClick:(entity: HomeTypeInfoEntity, position:Int)->Unit)  {
        onClickChooseFunction=onClick
    }

    override fun convert(holder: BaseDataBindingHolder<ItemHomeTypeBinding>, item: HomeTypeInfoEntity) {
        val binding =
            holder.dataBinding
        val variable = binding?.setVariable(BR.entity, item)
        binding?.setVariable(BR.adapter, this)
        binding?.setVariable(BR.position, holder.layoutPosition)

        binding?.executePendingBindings()
    }
}